<!DOCTYPE html>
<html lang="zh">
{include file="public/head"}
<link rel="stylesheet" type="text/css" href="/static/admin/js/webuploader/webuploader.css">
<body>
<div class="container-fluid">
  
  <div class="row">
    
    <div class="col-lg-12">
      <div class="card">
        <div class="card-body">
          
          <form class="row" id="common_form" action="{$action}" method="post">
            <div class="mb-3 col-md-12">
              <label for="username" class="form-label">头像</label>
              <div class="d-flex">
                {empty name="admin_info.avatar"}
                <img src="/static/admin/images/default_avatar.jpeg" class="rounded-circle me-3 show_upload_file" style="width: 120px;height: 120px">
                <input type="hidden" name="avatar" class="file_path_value" value="/static/admin/images/default_avatar.jpeg">
                {else /}
                <img src="{$admin_info.avatar}" class="rounded-circle me-3 show_upload_file" style="width: 120px;height: 120px">
                <input type="hidden" name="avatar" class="file_path_value" value="{$admin_info.avatar}">
                {/empty}
                <div>
                  <div class="filePicker">上传图片</div>
                  <button type="button" class="btn btn-success" onclick="openLayer('选择图片', '/admin/common/selectImage',100,100)">选择图片</button>
                </div>
              </div>
            </div>
            <div class="mb-3 col-md-12">
              <label for="type" class="form-label">所属角色</label>
              <div class="form-controls">
                <select name="group_id" class="form-select" id="group_id">
                    {volist name="auth_group" id="v1"}
                      <option value="{$v1.id}" {if $admin_info.group_id == $v1.id}selected="selected"{/if}>{$v1.name}</option>
                    {/volist}
                </select>
              </div>
            </div>
            <div class="mb-3 col-md-12">
              <label for="username" class="form-label">用户名</label>
              <input type="text" class="form-control" id="username" name="username" value="{$admin_info.username}" placeholder="请输入用户名" />
            </div>
            <div class="mb-3 col-md-12">
              <label for="phone" class="form-label">手机号</label>
              <input type="text" class="form-control" id="phone" name="phone" value="{$admin_info.phone}" placeholder="请输入手机号"  />
            </div>
            <div class="mb-3 col-md-12">
              <label for="password" class="form-label">密码</label>
              <input type="text" class="form-control" id="password" name="password" value="" placeholder="请输入密码"  />
            </div>
            <div class="mb-3 col-md-12">
              <label for="status" class="form-label">状态</label>
              <div class="clearfix">
                <div class="form-check form-check-inline">
                  <input type="radio" id="status" name="status" class="form-check-input" value="1" {if $admin_info.status == 1}checked{/if}>
                  <label class="form-check-label" for="status">启用</label>
                </div>
                <div class="form-check form-check-inline">
                  <input type="radio" id="status" name="status" class="form-check-input" value="0" {if $admin_info.status == 0}checked{/if}>
                  <label class="form-check-label" for="status">禁用</label>
                </div>
              </div>
            </div>
            <input type="hidden" name="salt" value="{$admin_info.salt}">
            <input type="hidden" name="id" value="{$admin_info.id}">
            <input type="hidden" id="jump_url" value="{$action}">
            <div class="mb-3 col-md-12">
              <button type="submit" class="btn btn-primary ajax-post" target-form="add-form">确 定</button>
              <button type="button" class="btn btn-default" id="close_layer_open">返 回</button>
            </div>
          </form>
          
        </div>
      </div>
    </div>
        
  </div>
  
</div>
{include file="public/script"}

<script type="text/javascript" src="/static/admin/js/webuploader/webuploader.js"></script>
<script type="text/javascript">
uploader = WebUploader.create({
    auto: true,
    server: '/admin/common/uploadImage',
    pick: {
        id:'.filePicker',
        //是否开启多个文件选择能力
        multiple:false,
    },
    formData: {
         _token:''
    },
    fileVal:'file',
})
//上传成功时的回调方法
uploader.on('uploadSuccess',function (file,res) {
    if(res.code == 200)
    {
        $('.file_path_value').val(res.data);
        $('.show_upload_file').attr('src', res.data);
    }else{
        showNotify(res.msg, 'danger', 1000, 'mdi mdi-information-outline', 'top', 'right');
    }
})
uploader.on( 'uploadError', function( file ) {
    showNotify('上传文件失败', 'danger', 1000, 'mdi mdi-information-outline', 'top', 'right');
});
</script>
</body>
</html>